import time
from alg2 import Solution
from gen2 import generate_test_cases

def run_test(n, primes):
    """运行单个测试并返回结果和运行时间"""
    solution = Solution()
    start_time = time.time()
    result = solution.nthSuperUglyNumber(n, primes)
    end_time = time.time()
    return result, end_time - start_time

def run_tests():
    """运行多个测试并显示结果"""
    test_cases = generate_test_cases(5)
    for i, (n, primes) in enumerate(test_cases):
        result, duration = run_test(n, primes)
        print(f"测试用例 {i+1}: n = {n}, primes = {primes}")
        print(f"结果: 第 {n} 个超级丑数 = {result}")
        print(f"运行时间: {duration:.6f} 秒\n")

if __name__ == "__main__":
    run_tests()    